package ru.tulupov.toyfactory.model;

public class Toy implements Playable {
	private ToyType type;
	private Color color;

	public Toy(ToyType type, Color color) {
		this.type = type;
		this.color = color;
	}

	@Override
	public void play() {
		type.playWithToy();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		if (obj == this) {
			return true;
		}

		if (obj instanceof Toy) {
			Toy toy = (Toy) obj;

			return (type == toy.type) && (color == toy.color);
		}

		return false;
	}

	@Override
	public int hashCode() {
		return 17 * type.hashCode() + 31 * color.hashCode();
	}

	@Override
	public String toString() {

		return String.format("Toy[%s, %s]", type, color);
	}
}
